﻿/*
	制作：彩虹工作室
	功能：挑战BOSS
	时间：2017年1月15日
*/
var format = function FormatString(c, length, content) {
    var str = "";
    var cs = "";
    if (content.length > length) {
        str = content;
    } else {
        for (var j = 0; j < length - content.getBytes("GB2312").length; j++) {
            cs = cs + c;
        }
    }
    str = content + cs;
    return str;
}
var status = -1;
var text;
var icon1 = "#fUI/Gateway/WorldSelect/icon/0#";
var icon2 = "#fUI/UIWindow/Quest/icon2/7#";
var supericon = "#fUI/Basic.img/BtClaim/normal/0#";
var warning = "#fUI/CashShop.img/CSBeauty/hairColor/Enable/1#";
var icon3 = "#fUI/GuildMark.img/Mark/Etc/00009003/3#"; //剑
var icon4 = "#fUI/GuildMark.img/Mark/Etc/00009003/10#"; //剑
var icon5 = "#fUI/GuildMark.img/Mark/Etc/00009003/14#"; //剑
var icon6 = "#fEtc/pachinkoCygnus.img/controller/base/2#"
var selection1;
var secondsel = false;

var t1 = "#fMob/9300703/move/0#"
var t2 = "#fMob/9300702/move/0#";//藍色小光
var t3 = "#fMob/9300704/move/0#";//藍色小光
var t4 = "#fMob/9300706/move/0#";//藍色小光

var b1 = "#fNpc/0000001/image2/1#";//拉圖斯
var b2 = "#fNpc/0000001/image2/2#";//希拉
var b3 = "#fNpc/0000001/image2/3#";//農機
var b4 = "#fNpc/0000001/image2/4#";//炎魔
var b5 = "#fNpc/0000001/image2/5#";//機器人
var b6 = "#fNpc/0000001/image2/6#";//龍王
var b7 = "#fNpc/0000001/image2/7#";;//妖精王
var b8 = "#fNpc/0000001/image2/8#";//皮卡啾
var b9 = "#fNpc/0000001/image2/9#";;//獅子王
var b10 ="#fNpc/0000001/image2/10#";//女皇
var b11 ="#fNpc/0000001/image2/11#";//森欄玩
var b12 ="#fNpc/0000001/image2/12#";//巴洛谷
var b13 ="#fNpc/0000001/image2/13#";//阿卡
var b14 ="#fNpc/0000001/image2/14#";//天狗
var b15 ="#fNpc/0000001/image2/15#";//烏魯斯
var b16 ="#fNpc/0000001/image2/16#";//六手邪神
var b17 ="#fNpc/0000001/image2/17#";//四王
var b18 ="#fNpc/0000001/image2/18#";//培羅德
var b19 ="#fNpc/0000001/image2/19#";//暴君
var b20 ="#fNpc/0000001/image2/20#";//史屋
var b21 = "#fNpc/0000001/image3/1#";//史屋
var b22 = "#fNpc/0000001/image3/2#";//史屋
var z1 = "#i4032868#";//藍色小光



var bosslist = [
    [b1, 220080000, [8500002]],
    [b16, 252030000, [8800200]],
    [b12, 105100100, [8830007, 8830000]],
    [b4, 211042300, [8800002, 8800102]],
    [b6, 240050400, [8810018, 8810122]],
    [b8, 270050000, [8820014, 8820304]],
    [b11, 807300100, [9421581, 9421583]],
    [b3, 811000099, [9450022]],
    [b5, 703020000, [9600086, 9600087]],
    [b7, 300030300, [5250007]],
    [b9, 211070000, [8840010]],
    [b10, 271040000, [8850012]],
    [b13, 272030300, [9300303]],
    [b2, 262030000, [9300600]],
     [b19, 401060000,[]],
    [b14, 800026000, [9400080, 9400080]],
    [b15, 970072200, [9400080]],
    [b18, 863000100,[]],
    [b17, 105200000,[]],
    [b20, 350060300,[]],
    [b22, 105300303,[]],



]

var bosslist2 = [
    ["【武陵道场】", 925020000],
    ["【BOSS競技】", 932200000],
    ["【深淵四王】", 105200000],
    ["【培 羅 德】", 863000100],
    ["【梅格涅斯】", 401060000],
    ["【黑暗史鳥】", 350060300],
]

function start() {
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode <= 0) {
        cm.dispose();
        return;
    } else {
        if (mode == 1) {
            status++;
        } else {
            status--;
        }

        if (status == 0) {
    			text = "   "+t1+t2+t3+t4+"\r\n\r\n";
    		 text += ""+z1+z1+z1+z1+z1+z1+z1+z1+z1+z1+"\r\n\r\n";
               text += "   #L1004#" + icon6 + "挑戰次數重置#l     #L1005#"+icon6+ "其他副本\r\n\r\n";
            bosslist.forEach(function (value, index, array) {
                text += "#r#L" + index + "#" + value[0] + "#l" + ((index + 1) % 3 == 0 ? "\r\n": "  ");
            });
            text += "\r\n\r\n#r";
           

            cm.sendSimple(text);


        } else if (status == 1) {
            selection1 = selection;
            if (selection < 100) { // bosslist
                var idd = bosslist[selection1][1];
                if (idd < 100000000) {
                    cm.dispose();
                    cm.openNpc(idd);
                } else {
                    var bosss = bosslist[selection1][2];
                    if (bosss != null && bosss.length > 1) {
                        secondsel = true;
                        cm.sendSimple("你這無知的傻瓜，那麼請選擇吧!\r\n#L0# #v3994116# #l#L1# #v3994117# #l");
                    } else if (bosss != null) {
                        showEnterBoss(bosslist[selection1][0], bosss[0], -1);
                    } else {
                        cm.sendOk("發生未知的錯誤.");
                        cm.dispose();
                    }
                }
            } else if (selection < 1000) { // bosslist2
                cm.warp(bosslist2[selection1 - 100][1]);
                cm.dispose();
            } else if (selection == 1000) { // 休闲副本
                cm.sendOk("休閒副本");
                cm.dispose();
            } else if (selection == 1001) { // 组队副本
                cm.sendOk("組隊副本");
                cm.dispose();
            } else if (selection == 1002) { // 超级副本
                cm.sendOk("超级副本");
                cm.dispose();
            } else if (selection == 1003) { // BOSS次数查询
                cm.dispose();
                cm.openNpc(2159359, 1)
            } else if (selection == 1004) { // BOSS次数重置
                cm.dispose();
                cm.openNpc(2159359, 2)
            } else if (selection == 1005) { // BOSS次数重置
                cm.dispose();
                cm.openNpc(2008)
            } else {
                cm.sendOk("未知選項");
                cm.dispose();
            }
        } else if (status == 2) {
            if (secondsel) {
                showEnterBoss(bosslist[selection1][0], bosslist[selection1][2][selection], selection);
            } else {
                if (selection == 2) {
                    status = -1;
                    action(1, 0, 0);
                } else {
                    cm.warp(bosslist[selection1][1]);
                    cm.dispose();
                }
            }
        } else if (status == 3) {
            if (selection == 2) {
                status = -1;
                action(1, 0, 0);
            } else {
                cm.warp(bosslist[selection1][1]);
                cm.dispose();
            }
        }
    }
}

function getIcon(index) {
    if (index > 0 && index < 10) {
        return "#fUI/Basic/LevelNo/" + index + "#";
    } else {
        return "";
    }
}

function showEnterBoss(basename, bossid, type) {
    var text = "" + (type == -1 ? "" : type == 0 ? "簡單" : "困難") + basename + "\r\n"
    text +="\r\n#L0# #r#e開始挑戰#n#b#l\t#L1# #e放棄挑戰#n#l #L2##d#e<<<返回到上一步#n#l\r\n\r\n\r\n#b" ;

    cm.sendSimple(text)
}
